package logic

import (
	"context"
	"netease/neteaserpc/neteaserpc"

	"netease/api/internal/svc"
	"netease/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type DelLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DelLogic {
	return &DelLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *DelLogic) Del(req *types.DelRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	del, err := l.svcCtx.Neteaserpc.Del(l.ctx, &neteaserpc.DelRequest{
		Id: req.Id,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Data:    nil,
			Code:    500,
		}, nil
	}
	return &types.Response{
		Message: "删除成功",
		Data:    del,
		Code:    200,
	}, nil
}
